import request from '@/utils/request'

export function login(data) {
	return request({
		url: '/login',
		method: 'post',
		data
	})
}

export function getInfo() {
	return request({
		url: '/check',
		method: 'get'
	})
}

export function logout() {
	return request({
		url: '/vue-element-admin/user/logout',
		method: 'post'
	})
}


//新增用户
export function user_create(para) {
	return request({
		url: '/user/create',
		method: 'post',
		data: para
	})
}

//编辑用户
export function user_update(para) {
	return request({
		url: '/user/update',
		method: 'post',
		data: para
	})
}

//删除用户
export function user_delete(para) {
	return request({
		url: '/user/delete',
		method: 'post',
		data: {
			ids: para
		}
	})
}

//用户列表
export function user_list(para) {
	return request({
		url: '/user/list',
		method: 'post',
		data: para
	})
}

//用户详情
export function user_view(id) {
	return request({
		url: '/user/view',
		method: 'get',
		params: {
			id
		}
	})
}

//获取用户权限
export function user_userRoles(id) {
	return request({
		url: '/user/userRoles',
		method: 'get',
		params: {
			id
		}
	})
}

//保存用户权限
export function user_commitUserRole(data) {
	return request({
		url: '/user/commitUserRole',
		method: 'post',
		data: {
			id: data.id,
			roleIds: data.roleIds,
		}
	})
}
